﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:awc="clr-namespace:Assergs.Windows.Controls"
    xmlns:aw="clr-namespace:Assergs.Windows"
	>

    <SolidColorBrush x:Key="NormalBorderBrush" Color="{x:Static aw:ListBoxPallet.NormalBorder}"/>
    <SolidColorBrush x:Key="WindowBackgroundBrush" Color="{x:Static aw:ListBoxPallet.WindowBackground}"/>
    <SolidColorBrush x:Key="DisabledBorderBrush" Color="{x:Static aw:ListBoxPallet.DisabledBorder}"/>
    
    <LinearGradientBrush x:Key="DisableBackGroundBrush">
        <GradientStop Color="{x:Static aw:ListBoxPallet.DisableBackGround1}"/>
        <GradientStop Color="{x:Static aw:ListBoxPallet.DisableBackGround2}"/>
    </LinearGradientBrush>

	<Style x:Key="{x:Type ListBox}" TargetType="ListBox">
		<Setter Property="SnapsToDevicePixels" Value="true"/>
		<!--<Setter Property="OverridesDefaultStyle" Value="true"/>-->
		<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
		<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
		<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
		<Setter Property="MinWidth" Value="120"/>
		<Setter Property="MinHeight" Value="95"/>

		<!-- Customize template will slowly! fix by new -->
		<Setter Property="Background" Value="{StaticResource WindowBackgroundBrush}"/>
		<Setter Property="BorderBrush" Value="{StaticResource NormalBorderBrush}"/>
		<Setter Property="BorderThickness" Value="1"/>

		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="ListBox">
					<Border
                      Name="Border"
                      Background="{StaticResource WindowBackgroundBrush}"
                      BorderBrush="{StaticResource NormalBorderBrush}"
                      BorderThickness="1"
                      CornerRadius="2">
						<ScrollViewer
                          Margin="0"
                          Focusable="false">
							<!--Chậm khi sử dụng StackPanel-->
							<!--<StackPanel Margin="2" IsItemsHost="True" />-->
							<VirtualizingStackPanel Margin="2" IsItemsHost="True" />
						</ScrollViewer>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsEnabled" Value="false">
							<Setter TargetName="Border" Property="Background" Value="{StaticResource DisableBackGroundBrush}" />
							<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
						</Trigger>
						<Trigger Property="IsGrouping" Value="true">
							<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>

		<Style.Triggers>
			<Trigger Property="IsEnabled" Value="false">
				<Setter Property="Background" Value="{StaticResource DisableBackGroundBrush}" />
				<Setter Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
			</Trigger>
			<Trigger Property="IsGrouping" Value="true">
				<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
			</Trigger>
		</Style.Triggers>

	</Style>	
</ResourceDictionary>